for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import {
Controller,
Inject,
BadRequestException,
UseGuards,
Param,
Delete
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { RemoveEventCommand } from 'src/Application/Calendar/Command/RemoveEventCommand';
import { ICommandBus } from 'src/Application/ICommandBus';
import { UserRole } from 'src/Domain/User/User.entity';
import { IdDTO } from 'src/Infrastructure/Common/DTO/IdDTO';
import { Roles } from 'src/Infrastructure/User/Decorator/Roles';
import { RolesGuard } from 'src/Infrastructure/User/Security/RolesGuard';
@Controller('events')
@ApiTags('Calendar')
@ApiBearerAuth()
@UseGuards(AuthGuard('bearer'), RolesGuard)
export class RemoveEventAction {
constructor(
@Inject('ICommandBus')
private readonly commandBus: ICommandBus
) {}
@Delete(':id')
@Roles(UserRole.PHOTOGRAPHER)
@ApiOperation({ summary: 'Remove event' })
public async index(@Param() { id }: IdDTO) {
try {
await this.commandBus.execute(new RemoveEventCommand(id));
} catch (e) {
throw new BadRequestException(e.message);
}